package cn.com.mrzheng.web.controller;

import cn.com.mrzheng.web.controller.base.BaseController;
import cn.com.mrzheng.web.entity.User;
import cn.com.mrzheng.web.entity.User;
import cn.com.mrzheng.web.server.impl.UserService;
import cn.com.mrzheng.web.server.impl.UserService;
import cn.com.mrzheng.web.server.interfaces.IUserService;
import cn.com.mrzheng.web.utils.Envelope;
import cn.com.mrzheng.web.utils.ServiceApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

// rest风格控制器
@RestController
//  跨域调用
@CrossOrigin(origins = ServiceApi.Config.CrossOrigin, maxAge = 3600)
public class UserController extends BaseController<User, UserService> {

    @Autowired
    UserService Server;

    // 获取列表
    @RequestMapping(value = ServiceApi.User.LIST, method = RequestMethod.GET)
    public Envelope list(String filter, String currentPage, String pageSize){
        return super.list(filter,currentPage,pageSize);
    }

    // 保存
    @RequestMapping(value = ServiceApi.User.SAVE, method = RequestMethod.POST)
    public Envelope saveEntity(String datajson){
        return super.saveEntity(datajson);
    }

    // 删除
    @RequestMapping(value = ServiceApi.User.DELETE, method = RequestMethod.GET)
    public Envelope deleteEntity(String id){
        return super.deleteEntity(id);
    }

    // 查找编辑数据
    @RequestMapping(value = ServiceApi.User.GET, method = RequestMethod.GET)
    public User getEntity(String id){
        User role = Server.getEntity(id);
        return role;
    }

//
//    // 登陆
//    @RequestMapping(ServiceApi.Login.LOGIN)
//    public String Login(String username, String password){
//        String state = userServer.login(username, password);
//        return state;
//    }
//
//    // 注册
//    @RequestMapping(value = ServiceApi.Login.RIGISTER)
//    public String Register(String username, String password){
//        String state = userServer.register(username, password);
//        return state;
//    }

}
